<template>
  <div class="app-container">
    <div class="app-container_conter">
      <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="100px"
               style="display: flex;align-items: flex-end;justify-content: space-between">
        <div>
          <el-form-item label="投保人" prop="name">
            <el-input v-model="queryParams.name" placeholder="请输入投保人" clearable size="small"
                      @keyup.enter.native="handleQuery"/>
          </el-form-item>
          <el-form-item label="保单号码" prop="insure_no">
            <el-input v-model="queryParams.insure_no" placeholder="请输入保单号码" clearable size="small"
                      @keyup.enter.native="handleQuery"/>
          </el-form-item>

          <el-form-item label="时间" prop="timeData">
            <el-date-picker
                style="width: 240px"
                size="small"
                v-model="queryParams.timeData"
                type="daterange"
                range-separator="-"
                value-format="yyyy-MM-dd"
                start-placeholder="生效时间"
                end-placeholder="失效时间">
            </el-date-picker>
          </el-form-item>
        </div>
        <el-form-item style="width: 150px;text-align: right">
          <el-button type="primary" size="mini" @click="handleQuery">搜索</el-button>
          <el-button type="info" size="mini" @click="resetQuery">重置</el-button>
        </el-form-item>
      </el-form>
      <el-row :gutter="10" class="mb8">
        <!-- <el-col :span="1.5">
          <el-button
              type="primary"
              plain
              icon="el-icon-plus"
              size="mini"
              @click="handleAdd"

          >新增
          </el-button>
        </el-col> -->
        <el-col :span="1.5">
          <el-button
              style="background: #0793FF;color: #FFFFFF"
              size="mini"
              :disabled="single"
              @click="handleUpdate"
              v-hasPermi="['insurance:user:edit']"
          >修改
          </el-button>
        </el-col>
        <el-col :span="1.5">
          <el-button
              type="info"
              size="mini"
              :disabled="multiple"
              @click="handleDelete"
              v-hasPermi="['insurance:user:remove']"
          >删除
          </el-button>
        </el-col>
        <el-col :span="1.5">
          <el-button
              type="primary"
              size="mini"
              @click="handleExport"
              v-hasPermi="['insurance:insureEli:import']"
          >导出
          </el-button>
        </el-col>
        <!--      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>-->
      </el-row>

      <el-table v-loading="loading" :data="insureEliList" @selection-change="handleSelectionChange"
                :header-cell-style="tableHeaderColor">
        <el-table-column type="selection" width="55" align="center"/>
        <el-table-column label="保单编号" align="center" prop="id" fixed/>
        <el-table-column label="保单号" align="center" prop="insure_no" fixed min-width="180px"/>
        <el-table-column label="上级用户" align="center" prop="create_by"/>
        <el-table-column label="保险/产品" align="center" prop="insure_name" min-width="150px"/>


        <!--            <el-table-column label="投保人电话" align="center" prop="phone1"/>-->
        <!--      <el-table-column label="投保人邮编" align="center" prop="commAddrAndPostcode1" />-->
        <!--      <el-table-column label="投保人邮箱" align="center" prop="email1" />-->
        <el-table-column label="被保险人" align="center" prop="name2" min-width="180px"/>
        <!--            <el-table-column label="被保险人电话" align="center" prop="phone2"/>-->
        <!--      <el-table-column label="出单保费" align="center" prop="approve_price" />-->

        <el-table-column label="被保险员工总数" align="center" prop="staff_count2" min-width="180px"/>
        <el-table-column label="保险起期" align="center" prop="insurance_time_start" min-width="120px"/>
        <el-table-column label="保险止期" align="center" prop="insurance_time_end" min-width="120px"/>
        <el-table-column label="创建时间" align="center" prop="create_time" min-width="120px"/>
        <!--      <el-table-column label="状态" align="center" prop="status" :formatter="statusFormat"/>-->
        <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right"
                         min-width="200px">
          <template slot-scope="scope">
            <!--          <el-button-->
            <!--              size="mini"-->
            <!--              type="text"-->
            <!--              icon="el-icon-edit"-->
            <!--              @click="handleUpdate(scope.row)"-->
            <!--              v-hasPermi="['insurance:user:edit']"-->
            <!--          >修改-->
            <!--          </el-button>-->
            <el-button
                size="mini"
                type="text"
                @click="handUserList(scope.row)"
                v-hasPermi="['insurance:user:list']"
            >查看人员
            </el-button>
            <el-button
                size="mini"
                type="text"
                @click="handDetails(scope.row)"
                v-hasPermi="['insurance:insureEli:list']"
            >详情
            </el-button>
            <!--          <el-button-->
            <!--            -->
            <!--            size="mini"-->
            <!--            type="text"-->
            <!--            icon="el-icon-warning-outline"-->
            <!--            v-hasPermi="['insurance:repordRecord:add']"-->
            <!--            @click="handlePolice(scope.row)"-->
            <!--          >报案-->
            <!--          </el-button>-->
            <!--          v-show="scope.row.insureNo!=null"-->
            <el-button
                size="mini"
                type="text"
                @click="handlossRecord(scope.row)"
                v-hasPermi="['insurance:repordRecord:confirm']"
            >理赔
            </el-button>
            <!--            v-show="scope.row.insureNo!=null"-->
            <!--          <el-button-->
            <!--              icon="el-icon-upload2"-->
            <!--              size="mini"-->
            <!--              type="text"-->
            <!--              v-hasPermi="['insurance:user:batchImport']"-->
            <!--              @click="handleApprove(scope.row)"-->
            <!--          >批单-->
            <!--          </el-button>-->
            <el-button
                size="mini"
                type="text"
                v-show="scope.row.insure_no==null"
                @click="addPolicy(scope.row)"
                v-hasPermi="['insurance:insureEli:setInsureNo']"
            >回填保单号
            </el-button>
            <el-button
                v-show="scope.row.insure_no!=null"
                size="mini"
                type="text"
                @click="updatePolicy(scope.row)"
                v-hasPermi="['insurance:insureEli:setInsureNo']"
            >修改保单号
            </el-button>
            <el-button
                style="color:#FF0000 "
                size="mini"
                type="text"
                @click="handleDelete(scope.row)"
                v-hasPermi="['insurance:user:remove']"
            >删除
            </el-button>
            <!--          <el-button-->
            <!--              size="mini"-->
            <!--              type="text"-->
            <!--              icon="el-icon-download"-->
            <!--              @click="handleWorld(scope.row)"-->
            <!--              v-hasPermi="['insurance:insureEli:import']"-->
            <!--          >导出-->
            <!--          </el-button>-->


          </template>
        </el-table-column>
      </el-table>
    </div>
    <div style="font-size: 14px;margin-top: 20px;">
      <span>总合同数:{{ total }} (份)</span>
      <span style="margin: 0 20px">总人数 :{{ staff_count }} (人)</span>
      <span>总金额:{{ sinsurance_fee_count }} (元)</span>
    </div>
        <pagination
            style="background: transparent;"
            v-show=" total>0"
            :total="total"
            :page.sync="queryParams.pageNum"
            :limit.sync="queryParams.pageSize"
            @pagination="getList"
        />
    <div>

    </div>
    <!-- 添加雇主责任险保单号 -->
    <el-dialog :title="title" :visible.sync="open" left width="400px" append-to-body>
      <el-form ref="Policy" :model="Policy" :rules="rules" label-width="80px">
        <!--        <el-row>-->
        <!--&lt;!&ndash;          <el-col :span="24">&ndash;&gt;-->
        <!--&lt;!&ndash;            <h3 style="text-align: center">添加保单号</h3>&ndash;&gt;-->
        <!--&lt;!&ndash;          </el-col>&ndash;&gt;-->
        <!--        </el-row>-->
        <el-form-item label="保单号" prop="insur_no">
          <el-input v-model="Policy.insur_no" placeholder="请输入保单号"></el-input>
        </el-form-item>
        <el-row>
          <el-col :span="24">
            <div style="text-align: center">
              <el-button type="info" @click="resetPolicy('Policy')">重置</el-button>
              <el-button type="primary" @click="getPolicy('Policy')">提交</el-button>
            </div>
          </el-col>
        </el-row>
        <el-form-item>

        </el-form-item>
      </el-form>

    </el-dialog>
    <el-dialog :title="title1" :visible.sync="open1" width="500px" append-to-body>
      <el-form ref="queryParams1" :model="queryParams1" :rules="rules1" label-width="120px">
        <el-form-item label="证件号码" prop="idCardNo">
          <el-input style="width: 230px" v-model="queryParams1.idCardNo" placeholder="请输入证件号码"></el-input>
          <el-button style="margin-left: 10px" type="primary" icon="el-icon-search" @click="getSearch('queryParams1')">
            搜索
          </el-button>
        </el-form-item>
      </el-form>
    </el-dialog>
    <el-dialog :title="upload.title" :visible.sync="upload.open1" width="650" append-to-body>
      <!--       accept=".csv,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel"-->
      <el-upload
          ref="upload"
          class="upload-demo"
          action :limit="1"
          :on-exceed="formHandleExceed"
          :file-list="formFileList"
          :on-remove="formHandleRemove"
          :http-request="handleUpdateForm"
          :before-upload="beforeUploadForm"
          :auto-upload="false"
          drag
      >
        <img src="../../../assets/images/Import.png" style="width: 83px;height: 91px;margin: 50px 0;"/>
        <div class="el-upload__text">
          将文件拖到此处，或
          <em>点击上传</em>
        </div>
        <div class="el-upload__tip" slot="tip">
          <!--          <el-checkbox v-model="upload.isSupportUpdate" />是否更新已经存在的用户数据-->
          <span style="display: inline-block;width: 250px"></span>
          <el-link type="info" style="font-size:12px;color: #00afff" @click="importTemplate">下载模板</el-link>
        </div>
        <div class="el-upload__tip" style="color:red" slot="tip">提示：仅允许导入“xls”或“xlsx”格式文件！</div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm">确 定</el-button>
        <el-button type="info" @click="upload.open1 = false">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  listInsureEli,
  getInsureEli,
  delInsureEli,
  addInsureEli,
  updateInsureEli,
  exportInsureEli,
  insureNo,
  exportWord
} from "@/api/insurance/insureEli";
import Template from "../../base/template/index";
import {batchSave, examines_single, importTemolate, importTemolate1, listUser} from "@/api/insurance/user";
import {addapprove} from "@/api/insurance/approveLog";
import {get_insure} from "@/api/insurance/approveLog";

export default {
  name: "index",

  components: {
    Template
  },
  data() {
    return {

      Policy: {
        //  投保id
        insur_id: '',
        insur_no: '',//保单号
      },
      rules: {
        insur_no: [
          {required: true, message: '请输入保单号', trigger: 'blur'},
          // { min:6,max:6, message: '请输入正确的保单号', trigger: 'blur' }
        ]
      },
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 雇主责任险保单表格数据
      insureEliList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      open1: false,
      title1: '',
      formFileList: [],//显示上传文件
      uploadFormFileList: [],//确定上传文件
      // 用户导入参数
      upload: {
        // 是否显示弹出层（用户导入）
        open1: false,
        // 弹出层标题（用户导入）
        title: "",
        // 是否更新已经存在的用户数据
        isSupportUpdate: false,
      },
      //状态字典
      statusOptions: [],
      // 查询参数用户参数
      queryParams1: {
        pageNum: 1,
        pageSize: 10,
        name: null,
        idCardNo: null,
      },
      rules1: {
        idCardNo: [
          {required: true, message: '请输入证件号码', trigger: 'blur'}
        ]
      },
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        insure_no: null,//保单号
        name: null,//投保人
        type: 1,//1保单列表
        timeData: [],//时间
        is_export: 0,// 是否导出 1导出 0不导出
        user_id: '',
        role_id: '',
      },
      // 查询参数
      queryParams2: {
        pageNum: 1,
        pageSize: 10,
        insure_no: null,//保单号
        name: null,//投保人
        type: 1,
        timeData: [],//时间
        is_export: 1,// 是否导出 1导出 0不导出
        is_all: 1,// 是否全选 1是 0否
        insure_id: '', //非全选导出，则数组传入选中保单id
      },
      //  保单信息
      infoUser: {},
      //  保单id:
      insureId: '',
      sinsurance_fee_count: '',//总金额
      staff_count: '',//总人数
    };
  },

  created() {

    var user = JSON.parse(localStorage.getItem('userInfo'));
    this.queryParams.user_id = user.userId;
    if (user.roles.length != 0) {
      this.queryParams.role_id = user.roles[0].roleId
    }
    this.getList();
    this.getDicts("insure_eli_status").then(res => {
      this.statusOptions = res.data;
    })
  },
  methods: {
    /* 修改表头颜色 */
    tableHeaderColor({rowIndex}) {
      if (rowIndex === 0) {
        return 'background-color: #304156;color: #fff;font-weight: 400;font-family: Microsoft YaHei;'
      }
    },
    //点击跳转到报案页面
    handlePolice(row) {
      this.infoUser = row;
      this.open1 = true;
      this.title1 = '用户证件号码'
    },
    handleApprove(row) {
      console.log('row', row)
      this.insureId = row.id
      this.upload.title = "添加批单";
      this.upload.open1 = true;
    },
    // 下载文件
    importTemplate() {
      var obj = {
        type: '1'
      }
      importTemolate1(obj).then(res => {
        // console.log('下载模板',res)
        if (res.code == 1) {
          let link = document.createElement('a'); // 创建a标签
          link.style.display = 'none';
          let objectUrl = res.data;
          link.href = objectUrl;
          link.click();
        }

      })
      // importTemolate(obj).then(res=>{
      //   this.download(res.msg);
      // })
    },
    //上传导入确定按钮
    submitFileForm() {
      this.$refs.upload.submit();
      // this.$refs.upload.submit();
    },
    //开始上传前验证
    beforeUploadForm(file) {
      // console.log('验证', file)
      //文件大小验证
      if (file.size / 1024 / 1024 > this.formMaxSize) {
        this.$message({
          message: `上传文件大小不能超过${this.formMaxSize}M!`,
          type: 'waning'
        })
        false
      }
      //  中文乱码处理
      if (file.raw) {
        let reader = new FileReader()//读取文件内容
        reader.readAsText(file.raw, 'gb2312')//防止中文乱码问题，不加reader.onload方法都不会触发
        reader.onload = function (e) {
          this.contentHtml = e.target.result;//txt文本内容，接下来就可以对其进行校验处理了
          console.log('contentHtml', this.contentHtml);
        }
      }
      //验证文件类型
      var testmsg = file.name.substring(file.name.lastIndexOf('.') + 1)
      const extension = testmsg === 'xlsx' || testmsg === 'xls' || testmsg === 'csv' || testmsg === 'XLS' || testmsg === 'XLSX'
      if (!extension) {
        this.$message({
          message: '上传文件只能是xlsx/xls/csv/XLS/XLSX格式',
          type: 'warning'
        })
      }
      return extension
    },
    //移除上传列表中的文件
    formHandleRemove(file, formFileList) {
      let that = this;
      for (let i = 0; i < that.uploadFormFileList.length; i++) {
        if (that.uploadFormFileList[i].pname === file.name) {
          that.uploadFormFileList.splice(i, 1);
          break;
        }
      }
    },
    // 允许上传文件个数验证
    formHandleExceed(files, formFileList) {
      // console.log('files', files)
      this.$message.warning(`当前限制选择 1 个文件，本次选择了 ${files.length} 个文件，共选择了 ${files.length + formFileList.length} 个文件`)
    },
    //上传文件
    handleUpdateForm(param) {
      // console.log('param', param)
      // console.log('isSupportUpdate',this.upload)
      let that = this;
      let formData = new FormData();
      // console.log('id', that.insureId)
      // formData.append('id', that.form.insureId)//额外参数
      formData.append('excel', param.file);
      formData.append('insure_id', that.insureId);
      // formData.append('isSupportUpdate',that.upload.isSupportUpdate)
      // console.log('param', formData);

      examines_single(formData).then(response => {
        // console.log('res2356', response);
        var that = this;
        if (response.code == 1) {

          that.$alert(response.msg, '标题名称', {
            confirmButtonText: '确定',
            callback: action => {
              if (response.data.length == 0) {
                this.upload.open1 = false;
              } else {
                that.$alert('是否要将添加用户部分错误的信息导出', '标题名称', {
                  confirmButtonText: '确定',
                  callback: action => {
                    if (action == 'confirm') {
                      let link = document.createElement('a'); // 创建a标签
                      link.style.display = 'none';
                      let objectUrl = response.data;
                      link.href = objectUrl;
                      link.click();
                      this.upload.open1 = false;
                    }
                  }
                });
              }
            }
          });
        }
      })
    },
    // 点击搜索，搜索对应的证件号码
    getSearch(queryParams1) {
      this.queryParams.pageNum = 1;
      // this.queryParams.idCardNo=this.form.idCardNo
      // console.log('queryParams1', this.queryParams1);
      this.$refs[queryParams1].validate((valid) => {
        if (valid) {
          listUser(this.queryParams1).then(res => {
            // console.log('res用户', res);
            if (res.rows.length != 0) {
              // this.show = true;
              // this.form.userId = res.rows[0].id;
              // this.form.name = res.rows[0].name;
              // this.form.idCardNo = res.rows[0].idCardNo;
              // this.form.actualUnit = res.rows[0].company;
              this.$router.push({
                path: '/business/applicationFiling/index',
              })
              this.$store.commit('Insure_User', res.rows[0]);
              this.$store.commit('Info_Insure', this.infoUser);

            } else {
              this.$message({
                message: '暂时没有这个人，请重新搜索查询',
                type: 'warning'
              })
              this.show = false
            }

          })
        }
      })
    },
    /** 查询雇主责任险保单列表 */
    getList() {
      this.loading = true;
      // console.log('queryParams12',this.queryParams)
      get_insure(this.queryParams).then(response => {
        // console.log('查询',response)
        this.insureEliList = response.data.list;
        // console.log('insureEliList', this.insureEliList);
        this.total = response.data.count;
        this.staff_count = response.data.number.staff_count
        this.sinsurance_fee_count = response.data.number.sinsurance_fee_count
        this.loading = false;
      });
    },
    //重置保单号
    resetPolicy(Policy) {
      this.$refs[Policy].resetFields();
    },
    //点击跳转到理赔页面
    handlossRecord() {
      this.$router.push({
        path: '/business/lossAmount/index'
      })
    },
    //提交保单号
    getPolicy(Policy) {
      this.$refs[Policy].validate((valid) => {
        if (valid) {
          insureNo(this.Policy).then(res => {
            if (res.code == 1) {
              this.$message({
                message: '添加保单号成功',
                type: 'success'
              });
            }
            // console.log('res',res)
            this.open = false
            this.getList();
          })
        } else {
          return false
        }
      })
    },
    //根据id将保单导出word
    handleWorld(row) {

      var that = this
      // var del=true;
      this.$confirm('是否确认将数据导出pdf?', "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(function () {
        // console.log('id',row.id)
        const loading = that.$loading({
          lock: true,
          text: '请耐心等待正在导出数据...',
          spinner: 'el-icon-loading',
          background: 'rgba(0, 0, 0, 0.7)'
        });
        exportWord(row.id).then(response => {
          loading.close();
          that.$message({
            message: '导出数据成功!',
            type: 'success'
          });
          // console.log('res',response);
          // var url=response.msg
          // window.location.href = url;
          that.download(response.msg);

        })
      }).then(response => {
      })
    },
    addPolicy(row) {
      this.title = "添加保单号"
      this.Policy.insur_id = row.id
      this.Policy.insur_no = '',
          this.open = true;
    },
    //点击修改按钮修改保单号
    updatePolicy(row) {
      this.title = "修改保单号"
      this.Policy.insur_id = row.id
      this.Policy.insur_no = row.insure_no
      // this.Policy.insur_no=row.insure_no.substring(15,21),
      this.open = true;
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },

    // 表单重置
    reset() {
      this.form = {
        id: null,
        insureNo: null,
        name1: null,
        phone1: null,
        commAddrAndPostcode1: null,
        email1: null,
        name2: null,
        phone2: null,
        commAddrAndPostcode: null,
        email2: null,
        nature2: null,
        industry: null,
        address2: null,
        businessScope2: null,
        staffCount2: null,
        seniorDescription: null,
        generalDescription: null,
        isELI: null,
        isLossEli: null,
        eliDesc: null,
        isII: null,
        isLossIi: null,
        iiDesc: null,
        isTrain: null,
        trainingTime: null,
        isHaveMedicalStaff: null,
        medicalStaffCount: null,
        hospitalDistance: null,
        hospitalName: null,
        isJoinMi: null,
        descriptionMi: null,
        compPrincipleAndLimit: null,
        otherDescription: null,
        casualtiesFeeLimit: null,
        medicalFeeLimit: null,
        legalFeeLimit: null,
        liabilityLimit: null,
        deductible: null,
        insuranceRate: null,
        insuranceTimeStart: null,
        insuranceTimeEnd: null,
        insuranceFeeCount: null,
        payTime: null,
        solution: null,
        seal: null,
        signingTime: null,
        agent: null,
        underwriting: null,
        signPolicyholder: null,
        signPolicyholderTime: null,
        createTime: null,
        updateTime: null,
        insUserIds: null,
        userPath: null,
        status: "0"
      };
      this.resetForm("form");
    },
    //状态字典翻译
    statusFormat(row, column) {
      return this.selectDictLabel(this.statusOptions, row.status);
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      // this.queryParams.timeData=[],//时间
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
      if (this.insureEliList.length == selection.length) {
        this.queryParams2.is_all = 1;
        this.queryParams2.insure_id = '';
      } else {
        this.queryParams2.is_all = 0;
        this.queryParams2.insure_id = this.ids;
        // console.log(33333333333333)
      }
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.$router.push({
        path: '/insureEli/add/'

      })
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      // console.log('row', row)
      this.$router.push({
        path: '/insureEli/edit/',
        query: {
          insureInfo: row
        }

      })
    },
    //TODO 待实现
    /** 批量导入按钮操作 */
    handBatchImport(row) {
      this.reset();
      const id = row.id || this.ids
      getRepordRecord(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "批量导入";
      });
    },
    //TODO 待实现
    /** 查看在保人员按钮操作 */
    handUserList(row) {
      this.$router.push({
        path: '/business/user/index',
        query: {
          insureInfo: row
        }
      })
      // this.$store.commit('Info_Insure', row)
    },
    //点击批单跳转到批单页面
    // handEndorsement(row) {
    //   this.$router.push({
    //     path: '/business/approve/index',
    //     query: {
    //       insureInfo: row
    //     }
    //   })
    //   this.$store.commit('Info_Insure', row)
    //
    // },
    //查看用户详情
    handDetails(row) {
      this.$router.push({
        path: 'ListApplication/details',
        query: {
          insureInfo: row
        }
      })
      // this.$router.push({
      //   path: '/insureEli/details/',
      //   query: {
      //     insureInfo: row
      //   }
      // })
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateInsureEli(this.form).then(response => {
              this.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addInsureEli(this.form).then(response => {
              this.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$confirm('是否确认删除雇主责任险保单编号为"' + ids + '"的数据项?', "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(function () {
        return delInsureEli(ids);
      }).then(() => {
        this.msgSuccess("删除成功");
        this.getList();
      })
    },
    /** 导出按钮操作 */
    handleExport() {
      var that = this;

      this.$confirm('是否确认导出保单数据项?', "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(function () {
        const loading = that.$loading({
          lock: true,
          text: '请耐心等待正在导出数据...',
          spinner: 'el-icon-loading',
          background: 'rgba(0, 0, 0, 0.7)'
        });
        console.log('queryParams2', that.queryParams2)
        get_insure(that.queryParams2).then(response => {
          // console.log('response',response)
          loading.close();
          let link = document.createElement('a'); // 创建a标签
          link.style.display = 'none';
          let objectUrl = response.data;
          link.href = objectUrl;
          link.click();
          that.$message({
            message: response.msg,
            type: 'success'
          });
          // that.download(response.msg);
        })
      }).then(response => {
        // console.log('response', response)

      })
    }
  }
}
</script>

<style scoped>
.app-container_conter {
  background: #F8FBFF;
  padding: 30px;
  border-radius: 10px;
  box-sizing: border-box;
}
</style>
